#! /usr/bin/python

import sys
import os
import re

if __name__ == "__main__":
	if (len(sys.argv) != 2):
		print sys.argv[0] + " trace"
		exit(-1)

	fo = open(sys.argv[1])
	als = fo.readlines()
	gld_request = 0
	gst_request = 0
	inst_issued = 0
	inst_executed = 0

	for line in als:
		if len(line.strip().split("gld_request")) == 2:
			tmp = line
			tmp = tmp.strip().split("gld_request")[0]
			p = re.compile("[\' \']*")
			result = p.split(tmp)
			time = int(result[0])
			avg = int(result[1])
			gld_request += time * avg

		elif len(line.strip().split("gst_request")) == 2:
			tmp = line
			tmp = tmp.strip().split("gst_request")[0]
			p = re.compile("[\' \']*")
			result = p.split(tmp)
			time = int(result[0])
			avg = int(result[1])
			gst_request += time * avg

		elif len(line.strip().split("inst_issued")) == 2:
			tmp = line
			tmp = tmp.strip().split("inst_issued")[0]
			p = re.compile("[\' \']*")
			result = p.split(tmp)
			time = int(result[0])
			avg = int(result[1])
			inst_issued += time * avg

		elif len(line.strip().split("inst_executed")) == 2:
			tmp = line
			tmp = tmp.strip().split("inst_executed")[0]
			p = re.compile("[\' \']*")
			result = p.split(tmp)
			time = int(result[0])
			avg = int(result[1])
			inst_executed += time * avg

	print "gld_request", gld_request 
	print "gst_request", gst_request 
	print "inst_issued", inst_issued 
	print "inst_executed", inst_executed

